<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Flask Calendar</title>
    <!-- 无效
    <link rel="icon" href="{{ url_for('static',filename='favicon.ico') }}">
    <link href="{{ url_for('static',filename='bootstrap.min.css') }}" rel="stylesheet">
    -->
    <link rel="stylesheet" type="text/css" href="../static/css/bootstrap.min.css"/>
</head>
<body>
    <div>
        <!-- 判断当前登录用户 session.get('username') -->
        {% if session.get('username') %}
            <h1>您好，{{ session.get('username') }}，欢迎来到我的小站</h1>
            <li><a href="{{ url_for('login.logout') }}">注销</a></li>
        {% else %}
            <li><a href="{{ url_for('login.login') }}">登录</a></li>
            <li><a href="{{ url_for('login.register') }}">注册</a></li>
        {% endif %}
    </div>
    <div>
        <form action="{{ url_for('login.index') }}" method="post">
            <table>
                <tbody>
                <tr>
                    <td>{{ form.year }}</td>
                    <td>{{ form.area }}</td>
                    <td>{{ form.submit }}</td>
                </tr>
                <tr>
                    <td style="background-color:hotpink;">
                        {% with messages = get_flashed_messages() %}
                           {% if messages %}
                              {% for message in messages %}
                                 {{ message }}
                              {% endfor %}
                           {% endif %}
                        {% endwith %}
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="container">
        {% if form.year.data=='None' or form.year.data==None %}
            <h3 class="text-center">Welcome to Flask Calendar {{date.year}} <small></small></h3>
        {% else %}
            <h3 class="text-center">Welcome to Flask Calendar {{form.year.data}} <small></small></h3>
        {% endif %}
        {% set week_addr = ['日', '一', '二', '三', '四', '五', '六'] %}
        {% for month_addr,monthInfo in content.items()%}
        <div class="col-lg-3">
            <!-- 展示月份 -->
            <h4 class="text-center">{{month_addr}}</h4>
            {% with _month=false %}
             <!-- 判断当前月份高亮展示 -->
            {% if month_addr == this_month %}
                <table style='background-color:#a6e1ec' class="table table-bordered">
                {% set _month = true %}
            {% else %}
                <table class="table table-bordered">
            {% endif %}
                    <!-- 展示周-->
                    <tr>
                        {% for addr in week_addr %}
                            <th>{{addr}}</th>
                        {% endfor %}
                    </tr>
                    <!-- 展示日期 -->
                    {% for weeks in monthInfo %}
                    <tr>
                        {% for day in weeks %}
                        {% if day == 0 %}
                            <td>&nbsp</td>
                        {% elif _month== true and day == date.day %}
                            <td style="background-color:hotpink;">{{ day }}</td>
                        {% elif day == '休' %}
                            <td style="background-color:hotpink;">{{ day }}</td>
                        {% else %}
                            <td>{{ day }}</td>
                        {% endif %}
                        {% endfor %}
                    </tr>
                    {% endfor %}
                    {% endwith %}
                </table>
        </div>
        {% endfor %}
    </div>
</body>
<footer class="text-center "><strong><a href="https://www.jianshu.com/u/d23fd5012bed">Flask Calendar By:dasunPython</a></strong></footer>
</html>